<?php 
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

defined('_JEXEC') or die('Retricted Access');

JFilterOutput::objectHTMLSafe( $this->item );
JHTML::_('behavior.tooltip');

global $jbconfig;
global  $option;
$user = JFactory::getUser();
$userdetail = JRequest::getVar('userdetail');
if ($this->temp_usertype=='')
{
	$group = JRequest::getVar('group', '');
	if ($group=='')
	{
		if ($user->getParam('AccountType'))
			$group = $user->getParam('AccountType');
		else 
			$group = 'Job Seeker User';
	}		
}
else 
	$group = $this->temp_usertype;
	

$userdetail = JRequest::getVar('userdetail');
JHTML::stylesheet('ja.jobboard.css', 'components/'. JBCOMNAME .'/css/');	

JFilterOutput::objectHTMLSafe( $user, ENT_QUOTES, '' );

if ($this->user->get('lastvisitDate') == "0000-00-00 00:00:00") {
	$lvisit = JText::_( 'Never' );
} else {
	$lvisit	= generateDate($this->user->get('lastvisitDate'));
}

if (JRequest::getVar('save')!='success')
{	
?>
<div id="jobboard-content">

<h2><?php echo JText::_('Step 2').': '.JText::_('Update your information'); ?></h2>

<script type="text/javascript" language="javascript">
/* <![CDATA[ */
	window.onload = function () {
		if ($("usergroup0") != null) {
			$("usergroup0").addEvent('click', function() {
			div_jobseeker = document.getElementById('jobseeker');
			div_employer = document.getElementById('employer');
			div_jobseeker.style.display = 'block';
			div_employer.style.display = 'none';
			
			});
			}
			if ($("usergroup1") != null ) {
			$("usergroup1").addEvent('click', function() {
			div_jobseeker = document.getElementById('jobseeker');
			div_employer = document.getElementById('employer');
			div_jobseeker.style.display = 'none';
			div_employer.style.display = 'block';
			});
			}

	}
	
	function submitbutton_resumeForm(pressbutton)
	{
		form = document.resumeForm;
		form.task.value = pressbutton;
		form.submit();
	}
	function submitbutton_profileForm(pressbutton)
	{
		form = document.profileForm;
		form.task.value = pressbutton;
		form.submit();
	}
	
/* ]]> */
</script>
	<form name="userdetailForm" action="<?php echo JURI::root();?>index.php" method="post">	
		<div class="moduletable usergroup-box"> 	    
		  	<h3>
	        	<?php echo JText::_( 'Account info' ); ?>
	    	</h3>	
	    	<table class="tabledata usergroup-details">
	    		<tr class="first">			
					<td width="150" class="key">
						<?php echo JText::_( 'Name' ); ?>
					</td>
					<td>
						<?php echo $this->user->get('name'); ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<?php echo JText::_( 'Username' ); ?>
					</td>
					<td>
						<?php echo $this->user->get('username'); ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<?php echo JText::_( 'Email' ); ?>
					</td>
					<td>
						<?php echo $this->user->get('email'); ?>
					</td>
				</tr>
			
				<?php if ($this->me->authorize( 'com_users', 'block user' )) { ?>
				<tr>
					<td class="key">
						<?php echo JText::_( 'Block User' ); ?>
					</td>
					<td>
						<?php echo $this->lists['block']; ?>
					</td>
				</tr>
				<?php } if ($this->me->authorize( 'com_users', 'email_events' )) { ?>
				<tr>
					<td class="key">
						<?php echo JText::_( 'Receive System Emails' ); ?>
					</td>
					<td>
						<?php echo $this->lists['sendEmail']; ?>
					</td>
				</tr>
				<?php } if( $this->user->get('id') ) { ?>
				<tr>
					<td class="key">
						<?php echo JText::_( 'Register Date' ); ?>
					</td>
					<td>
						<?php echo generateDate($this->user->get('registerDate'));?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<?php echo JText::_( 'Last Visit Date' ); ?>
					</td>
					<td>
						<?php echo $lvisit; ?>
					</td>
				</tr>
				<?php } ?>						
			</table>
		
		
		<input type="hidden" name="cid" value="<?php echo $this->user->id; ?>" />
		<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
		<input type="hidden" name="view" value="usergroup" />
		<input type="hidden" name="task" value="" />
		<?php echo JHTML::_( 'form.token' ); ?>	
		
		</div>
       
		<?php if ($this->temp_usertype=='') { ?>
		<div class="moduletable usergroup-box"> 
		<?php  
			if (getCurrentUserType()=='Guest')
				if (!$user->getParam('AccountType'))
				{
					?>
					<h3>
			        	<?php echo JText::_( 'Account type' ); ?>
			    	</h3>
			    	<?php
					if ($group=='Job Seeker User')
						echo $this->displayUserGroup(0);
					else 
						echo $this->displayUserGroup(1);
				}
			?>
		</div>
		<?php } ?>	
	</form>	
	
	
	<?php if (($group == 'Job Seeker User')){?>
	<div id="jobseeker">
	<?php }else {?>
	<div id="jobseeker" style="display: none;">
	<?php }?>
		<h2><?php echo JText::_('Resume detail'); ?></h2>
		<form name="resumeForm" action="index.php" method="post" enctype="multipart/form-data">
		<div class="moduletable usergroup-box"> 		    
	 		<h3>
          		<?php echo JText::_("General Details")?>
      		</h3>
			<table class="tabledata">		    	
	            <?php
	            $k=0;
	            for($i = 0, $n = count($this->fieldlist); $i < $n; $i++ ){
	                $field = $this->fieldlist[$i];
	                $field_name = $field->field_name;
	                if($field->display=='admin_only')
	                    continue;
	                ?> 
	                <?php if($field->field_type=='SEPERATOR' && $field->display!='hide_all'){?>	
				    	</table>
				    							
						<table class="tabledata">
							<tr>
			                	<th  colspan="3">
				                    <h3><?php echo JText::_($field->label);?></h3>
	                    			
				                </th>
			                </tr>
			                <?php }else{ ?>  
			               		<?php
		                    	$edit = $this->item_resume->id?true:false;			                        
		                    	$input = rendfield($this->item_resume, $field, false, $edit);
				                if($field->display=='hide_all'){
					        		echo $input; 
					        		continue;
					        	}
		                        ?>
		                        <?php if($input!='' && ((!$edit && $field->display!='hide_on_new') || $edit)){?>
			               		<tr class="row<?php echo $k; ?>">
			                        <td width="20%" style="text-align:left;" valign="top">
			                        <?php echo JText::_($field->label); ?>:
			                        </td>
			                        <td width="10">&nbsp;</td>
			                        <td width="80%">
			                           <?php echo $input;?>
			                        </td>
			                    </tr>      
				                
			                	<?php }
			               }
			        
	                		$k = 1 - $k;
				            }
				            ?>
							
	            
		    			</table>
		
					    <table class="tabledata">
					        <tr>
					            <td>
					                <input class="button" type="button" onclick="submitbutton_resumeForm('save_resume');" value="<?php echo JText::_('Save'); ?>" />
					                <input class="button" type="button" onclick="submitbutton_resumeForm('cancel_resume');" value="<?php echo JText::_('Cancel'); ?>" />
					            </td>
					        </tr>
					    </table>	
					    <input type="hidden" name="edit_resume" value="<?php echo ($this->item_resume->id)?true:false; ?>" />
					    <input type="hidden" name="userdetail" value="<?php echo $userdetail;	 ?>" />
					    <input type="hidden" name="user_id" value="<?php echo $user->id;	 ?>" />
					    <input type="hidden" name="group" value="Job Seeker User" />
						<input type="hidden" name="view" value="jacandidates" />
						<input type="hidden" name="cid[]" value="<?php echo $this->item_resume->id; ?>" />
						<input type="hidden" name="id" value="<?php echo $this->item_resume->id; ?>" />
						<input type="hidden" name="option" value="<?php echo JBCOMNAME; ?>" />
						<input type="hidden" name="view" value="jausergroup" />
						<input type="hidden" name="task" value="" />
					    <input type="hidden" name="limited" value="<?php echo JRequest::getVar('limited', 1); ?>" />
						<input type="hidden" name="boxchecked" value="1" />
					    <input type="hidden" name="Itemid" value="<?php echo $this->Itemid; ?>" />	
						<?php echo JHTML::_( 'form.token' ); ?>	
			</table>
		</div>				    			
		</form> 
	</div>
	
	<?php if (($group == 'Employer User')){?>	
 	<div id="employer">
	<?php }else{?>
	<div id="employer" style="display: none;">
	<?php }?>
	<h2><?php echo JText::_('Profile detail'); ?></h2>
 	<form name="profileForm" action="index.php" method="post" enctype="multipart/form-data">
		<div class="moduletable"> 		    
		 	<h3>
	        	<?php echo JText::_("General Details")?>
	      	</h3>
			
			<table class="tabledata">		    
	            <?php
	            $k=0;
	            for($i = 0, $n = count($this->em_fieldlist); $i < $n; $i++ ){
	                $field = $this->em_fieldlist[$i];
	                $field_name = $field->field_name;
	                if($field->display=='admin_only')
	                    continue;
	                ?> 
	              <?php if($field->field_type=='SEPERATOR' && $field->display!='hide_all'){?>	
				  </table>
				    							
						<table class="tabledata">
							<tr>
			                	<th  colspan="3">
				                    <h3><?php echo JText::_($field->label);?></h3>
	                    			  
				                </th>
			                </tr>
							<?php } else { ?>  
               		<?php
		                  	$edit = $this->item_profile->id?true:false;			                        
		                  	$input = rendfield($this->item_profile, $field, false, $edit);
							if($field->display=='hide_all'){
				        		echo $input; 
				        		continue;
				        	}
                      ?>
                      <?php if($input!='' && ((!$edit && $field->display!='hide_on_new') || $edit)  ){ ?>
               		<tr class="row<?php echo $k; ?>">
                        <td width="20%" style="text-align:left;" valign="top">
                        <?php echo JText::_($field->label); ?>:
                        </td>
                        <td width="10">&nbsp;</td>
                        <td width="80%">
                           <?php echo $input;?>
                        </td>
                    </tr>      
	                
                	<?php }
	                }			       
	                $k = 1 - $k;
			            }
			            ?>
						
			            
				    </table>
					<table class="tabledata">
				        <tr>
				            <td>
				                <input class="button" type="button" onclick="submitbutton_profileForm('save_profile');" value="<?php echo JText::_('Save'); ?>" />
		                		<input class="button" type="button" onclick="submitbutton_profileForm('cancel_profile');" value="<?php echo JText::_('Cancel'); ?>" />
				            </td>
				        </tr>
				    </table>	
				    <input type="hidden" name="edit_profile" value="<?php echo ($this->item_profile->id)?true:false; ?>" />
				    <input type="hidden" name="userdetail" value="<?php echo $userdetail;	 ?>" />
				    <input type="hidden" name="group" value="Employer User" />
					<input type="hidden" name="user_id" value="<?php echo $user->id;	 ?>" />
					<input type="hidden" name="view" value="employers" />
					<input type="hidden" name="cid[]" value="<?php echo $this->item_profile->id; ?>" />
					<input type="hidden" name="id" value="<?php echo $this->item_profile->id; ?>" />
					<input type="hidden" name="option" value="<?php echo JBCOMNAME; ?>" />
					<input type="hidden" name="view" value="jausergroup" />
					<input type="hidden" name="task" value="" />
				    <input type="hidden" name="limited" value="<?php echo JRequest::getVar('limited', 1); ?>" />
					<input type="hidden" name="boxchecked" value="1" />
				    <input type="hidden" name="Itemid" value="<?php echo $this->Itemid; ?>" />	
					<?php echo JHTML::_( 'form.token' ); ?>	
				
				</div>
			   
		
		 	</form> 
		 	</div>
		</div>
<?php 
}	
else
{
?>
<dl id="system-message">
<dt class="message">Message</dt>
<dd class="message message fade">
	<ul>
		<li><br/><?php 
					if (JRequest::getVar('user_type')=='employer') 
						echo JText::_('Successfully updated your profile details<br/>Please wait for admin approval before you can perform other activities as an employer');
					else 
						echo JText::_( 'Successfully updated your resume details'). '<br/>'.JText::_('Please wait for admin approval before you can perform other activities as a job seeker' );
				?>
		</li>
	</ul>
</dd>
</dl>
<?php 
}
?>